package hzmg.akkacloud.server;

import hzmg.akkacloud.server.common.utils.PropertyUtils;
import hzmg.akkacloud.server.remote.transport.starter.AkkaStarter;
import hzmg.akkacloud.server.remote.transport.starter.VertXStarter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * akkacloud-server entry
 *
 * @author zbw
 * @since 2022/7/21
 */
@Slf4j
@EnableScheduling
@SpringBootApplication
@ComponentScans(value = {@ComponentScan("hzmg.akkacloud.server.*")})
public class AkkaCloudServerApplication {

/*    private static final String TIPS = "\n\n" +
            "******************* AkkaCloud Tips *******************\n" +
            "如果应用无法启动，我们建议您仔细阅读以下文档来解决:\n" +
            "if server can't startup, we recommend that you read the documentation to find a solution:\n" +
            "\n" +
            "******************* AkkaCloud Tips *******************\n\n";*/

    public static void main(String[] args) {

        pre();

        AkkaStarter.init();
        VertXStarter.init();

        // Start SpringBoot application.
        try {
            //SpringApplication.run(AkkaCloudServerApplication.class, args);
            new SpringApplicationBuilder(AkkaCloudServerApplication.class)
                    .web(WebApplicationType.NONE)
                    .run(args);
        } catch (Throwable t) {
            //log.error(TIPS);
            log.error("启动失败，失败原因为:{}",t.toString());
            throw t;
        }
    }

    private static void pre() {
        //log.info(TIPS);
        PropertyUtils.init();
    }

}
